Use LanguageWire
GO


-- ================================================
-- Template generated from Template Explorer using:
-- Create Trigger (New Menu).SQL
--
-- Use the Specify Values for Template Parameters 
-- command (Ctrl-Shift-M) to fill in the parameter 
-- values below.
--
-- See additional Create Trigger templates for more
-- examples of different Trigger statements.
--
-- This block of comments will not be included in
-- the definition of the function.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE TRIGGER dbo.CustomerJobUpdate
ON [dbo].[CustomerJobs]
FOR UPDATE 
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	Update CustomerJobsToSync Set
		UpdateFlag = 1
	Where 
		JobId IN (SELECT JobID FROM Inserted)
		
    -- Insert statements for trigger here

END
GO

/****** Object:  Table [dbo].[CustomerJobsToSync]    Script Date: 01/05/2012 12:41:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


CREATE TABLE [dbo].[CustomerJobsToSync](
	[Id] [uniqueidentifier] NOT NULL,
	[JobId] [int] NOT NULL,
	[UpdateFlag] [bit] NOT NULL,
	[TimeStamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_CustomerJobsToSync] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


CREATE TABLE [dbo].[EntitiesToSync](
	[ObjectType] [nvarchar](50) NOT NULL,
	[CurrentTimeStamp] [timestamp] NOT NULL,
 CONSTRAINT [PK_EntitiesToSync] PRIMARY KEY CLUSTERED 
(
	[ObjectType] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO


USE TranslationOnline
GO

CREATE PROCEDURE dbo.utf_sp_GetProgressByJobId
@JobId INT
AS

Select 
	isnull(Progress, 0) TranslationProgress,
	isnull(ValidationProgress, 0) ValidationProgress,
	isnull(ProofreadingProgress, 0) ProofreadingProgress
from TranslatedDocument
Where
JobID = @JobId
GO
